package com.zhiche.lisa.bms.service.bill.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.bms.dao.mapper.bill.BillDetailMapper;
import com.zhiche.lisa.bms.dao.model.bill.Bill;
import com.zhiche.lisa.bms.dao.model.bill.BillDetail;
import com.zhiche.lisa.bms.service.bill.BillDetailService;
import com.zhiche.lisa.core.supports.BaseException;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 账单明细 服务实现类
 * </p>
 *
 * @author liuanshun
 * @since 2018-09-06
 */
@Service
public class BillDetailServiceImpl extends ServiceImpl<BillDetailMapper, BillDetail> implements BillDetailService {
    @Override
    public List<BillDetail> getBillDetailList(Long billId) {
        EntityWrapper<BillDetail> ew = new EntityWrapper<>();
        ew.eq("bill_id", billId);
        return this.selectList(ew);
    }

    /**
     * 根据多个账单ID,得到账单明细
     *
     * @param billIds
     * @return
     */
    @Override
    public List<BillDetail> getBillDetailList(List<Long> billIds) {
        if (CollectionUtils.isEmpty(billIds)) {
            throw new BaseException("账单ID不能为空！");
        }
        EntityWrapper<BillDetail> ew = new EntityWrapper<>();
        ew.in("bill_id", billIds);
        return this.selectList(ew);
    }

    @Override
    public List<Bill> getBillByfeeId(List<Long> feeIds) {
        return baseMapper.getBillByfeeId(feeIds);
    }
}
